package com.fudan.es.aggs.entity;

import java.lang.reflect.Method;

public class AggsPack {
	private String name;
	private AggsPack(String name) {
		this.name = name;
	}
	public Object getAggs(Object aggs) throws Exception {
		Method fetchAggs = aggs.getClass().getMethod("getAggregations");
		Object agg = fetchAggs.invoke(aggs, null);
		Method getAgg = agg.getClass().getMethod("get", String.class);
		Object resp = getAgg.invoke(agg, name);
		return resp;
	}
	public static AggsPack build(String name) {
		return new AggsPack(name);
	}
}
